package com.eco.fanliapp.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.AppWithdrawal;
import com.eco.fanliapp.vo.AppWithdrawalOfMode;
import com.eco.fanliapp.vo.WithdrawalInfo;
import com.github.pagehelper.PageInfo;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 提现记录 服务层
 * 
 * @author xiaoxx
 * @date 2019-05-14
 */
public interface IAppWithdrawalService extends IService<AppWithdrawal>
{
	/**
     * 查询提现记录信息
     * 
     * @param id 提现记录ID
     * @return 提现记录信息
     */
	AppWithdrawal selectAppWithdrawalById(Long id);
	
	/**
     * 查询提现记录列表
     * 
     * @param appWithdrawal 提现记录信息
     * @return 提现记录集合
     */
	List<AppWithdrawal> selectAppWithdrawalList(AppWithdrawal appWithdrawal);
	
	/**
     * 新增提现记录
     * 
     * @param appWithdrawal 提现记录信息
     * @return 结果
     */
	int insertAppWithdrawal(AppWithdrawal appWithdrawal);
	
	/**
     * 修改提现记录
     * 
     * @param appWithdrawal 提现记录信息
     * @return 结果
     */
	int updateAppWithdrawal(AppWithdrawal appWithdrawal);
		
	/**
     * 删除提现记录信息
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	int deleteAppWithdrawalByIds(String ids);

	/**
	 * 提现记录新增
	 * @param money
	 * @param appUserId
	 * @return
	 */
	ServerResponse<List<JSONObject>> addAppCashwithdrawal(String money, Long appUserId);

	/**
	 * 提现记录查询
	 * @param appUserId
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	ServerResponse<List<AppWithdrawal>> findAppWithdrawalByAll(Long appUserId, Integer pageNum,
                                                               Integer pageSize);


	HashMap<String, Object> selectAppWithdrawalBybalanceCount(Long userId, Integer i);

    /**
     *  动态字段,写入数据库记录
     *
     * @param withdrawal
     */
    ServerResponse insertSelective(AppWithdrawal withdrawal);

    /**
     * 查询所有提现详情
     * @return
     */
    ServerResponse<PageInfo> selectAppWithdrawalList(Integer currentPage, Integer pageSize, Integer companyId, Integer withdrawalType, Long userId, Integer status,String startTime,String endTime,String keyWord,Integer transferState,String dealStartTime,String dealEndTime);


    /**
     * 根据用户id查询提现详情
     * @param userId
     * @return
     */
    WithdrawalInfo selectAppWithdrawalByUserId(Long userId, Integer currentPage, Integer pageSize);

    /**
     *  根据主键来更新符合条件的数据库记录,bsm_withdrawal
     *
     * @param withdrawal
     */
    ServerResponse insertOrUpdateSelective(AppWithdrawal withdrawal);


    /**
     * 根据条件模糊查询提现详情
     * @param applicantStatus
     * @param startTime
     * @param endTime
     * @param keyWord
     * @return
     */
    ServerResponse<PageInfo> selectAppWithdrawalListByKeyWord(Integer applicantStatus, String startTime, String endTime, String keyWord, Integer currentPage, Integer pageSize, Integer companyId);

    /**
     * 根据条件下载提现信息
     * @param startTime
     * @param endTime
     * @param keyWord
     * @return
     */
    void downloadAppWithdrawalDetailsByKeyWord(HttpServletResponse response, Integer applicantStatus, String startTime, String endTime, String keyWord, Integer companyId);

    int updateSum(HashMap<String, Object> hashMap);

    int updateRefuseSum(HashMap<String, Object> hashMap);

	int deleteAppWithdrawalById(Long id);


	/**
	 * 提现记录查询（app轮播消息）
	 * @return
	 */
	ServerResponse findAll();

	/**
	 * easypoi 导出
	 * @param response
	 * @param applicantStatus
	 * @param startTime
	 * @param endTime
	 * @param keyWord
	 * @param companyId
	 */
	void export(HttpServletResponse response, Integer applicantStatus, String startTime, String endTime, String keyWord, Integer companyId,Integer withdrawalType,Integer transferState,String dealStartTime,String dealEndTime);


	/**
	 * easypoi 导入
	 * @param response
	 */
	List<AppWithdrawalOfMode> importExcel(HttpServletResponse response, MultipartFile file);


	List<AppWithdrawal> selectByUserIdAndAmount(Long userId, Double amount, Integer status);

	Double statisticsAmount(Integer companyId,Integer flag);

	/**
	 * 查询用户提现详情
	 * @param currentPage
	 * @param pageSize
	 * @param userId
	 * @return
	 */
	ServerResponse<PageInfo> findUserGetMoneyDetails(int currentPage, int pageSize, Long userId);

	/**
	 * 支付宝提现，实时到账
	 * @param money
	 * @param userId
	 * @return
	 */
    ServerResponse<List<JSONObject>> withdrawalsRecordToAliPay(String money, Long userId);

	Integer statisticsPeopleAmount(Integer companyId, Integer flag);

	Integer statisticsAmountNum(Integer companyId, Integer applicantStatus, Integer type, Long startDate, Long endDate);

	Double statisticsAmountMoney(Integer companyId, Integer applicantStatus, Integer type, Long startDate, Long endDate);

	Double sqjdWithdrawal();

	Double withdrawalAllMoney(Integer type);

	Map<String,Object> withdrawalCommision(Integer type);

	Double sqjdWithdrawalCommision();

	Map<String,Object> withdrawalResultCommision(Integer type, Integer flag);

	List<String> selectUserIdList();

//	void addSyUserMoneyLog(Long userid, BigDecimal Balance, BigDecimal amount, String remark, Integer logType, Integer logStatus);

}
